package com.gaofeng.day12;

import java.util.Random;

public class Role2 {
    private  String name;
    private int blood;
    private String face;
    private char gender;

    String[] boyface = {"风流俊雅","气字轩品","相毂关俊","五官正","相较平平","一塌糊涂","面目狰狞"};
    String[] girlface = {"美奂绝伦","沉鱼落厂","婷婷玉立","身材娇好","相貌平平","相貌简所","不忍睹"};
    String[] attack_desc = {
            "%s使出了一招【背心钉】,转到对方的身后,一零向%s背心的关台穴拍去。",
            "%s使出了一招【游空探爪】。飞起身形自半空中变章为抓锁向%s。",
            "%s人喝一声,身形下伙,一招【劈雷坠地】,捶向%s双腿。",
            "%s运气于景,一瞬间常心变得血红,一式【京心需】,推向%s。",
            "%s明手翻起阳手跟进,一招【没遮拦】,结结实实的捶向%s。",
            "%s上步抢身,招中套报,一招【劈挂连环】,连环攻向%s。"
    };
    String[] injured_desc= {
            "结果%s退了半步,毫发无损",
            "结果给%s适成一处察伤",
            "结果一击命中。%s痛得弯下服",
            "结果%s痛苦地闷哼了一声,是然受了点内伤",
            "结果xs摇摇晃晃,一跤摔倒作地",
            "结果%s脸色一下变得惨白,连逖了好几步",
            "结果「轰】的一声,%s口中鲜血狂喷面出",
            "结果%s一声惨叫,像滩软泥般塌了下去"
    };

    public Role2() {
    }

    public Role2(String name, int blood,  char gender) {
        this.name = name;
        this.blood = blood;
        this.gender = gender;
        setFace(gender);
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return blood
     */
    public int getBlood() {
        return blood;
    }

    /**
     * 设置
     * @param blood
     */
    public void setBlood(int blood) {
        this.blood = blood;
    }

    /**
     * 获取
     * @return face
     */
    public String getFace() {
        return face;
    }

    /**
     * 设置
     * @param face
     */
    public void setFace(char face) {
        Random rd = new Random();
        if(gender == '男'){
            int index = rd.nextInt(boyface.length);
            this.face = boyface[index];
        }else if(gender == '女'){
            int index = rd.nextInt(girlface.length);
            this.face = girlface[index];
        }else{
            this.face = "面目狰狞";
        }
    }

    /**
     * 获取
     * @return gender
     */
    public char getGender() {
        return gender;
    }

    /**
     * 设置
     * @param gender
     */
    public void setGender(char gender) {
        this.gender = gender;
    }

    public String toString() {
        return "Role2{name = " + name + ", blood = " + blood + ", face = " + face + ", gender = " + gender + "}";
    }

    public void attack(Role2 role){
        Random r = new Random();
        int index = r.nextInt(attack_desc.length);
        String kungfu = attack_desc[index];
        System.out.printf(kungfu,this.getName(),role.getName());
        System.out.println("");
        Random rd = new Random();
        int hurt = rd.nextInt(20) + 1;
        int remainBlood = role.getBlood() - hurt;
        remainBlood = Math.max(0,remainBlood);
        role.setBlood(remainBlood);


        if(remainBlood > 90){
            System.out.printf(injured_desc[0],role.getName());
        }else if(remainBlood > 80 && remainBlood <= 90){
            System.out.printf(injured_desc[1],role.getName());
        }else if(remainBlood > 70 && remainBlood <= 80){
            System.out.printf(injured_desc[2],role.getName());
        }else if(remainBlood > 60 && remainBlood <= 70){
            System.out.printf(injured_desc[3],role.getName());
        }else if(remainBlood > 40 && remainBlood <= 60){
            System.out.printf(injured_desc[4],role.getName());
        }else if(remainBlood > 20 && remainBlood <= 40){
            System.out.printf(injured_desc[5],role.getName());
        }else if(remainBlood > 10 && remainBlood <= 20){
            System.out.printf(injured_desc[6],role.getName());
        }else{
            System.out.printf(injured_desc[7],role.getName());
        }
        System.out.println("");
    }

   public void showRoleInfo(){
       System.out.println("姓名为："+getName());
       System.out.println("血量为："+getBlood());
       System.out.println("性别为："+getGender());
       System.out.println("长相为："+getFace());
   }

}
